//
//  FFObject.h
//  ForceField
//
//  Created by Roxanne Brittain on 11/15/11.
//  Copyright (c) 2011 Digifit. All rights reserved.
//

#import <UIKit/UIKit.h>
#include <math.h>
#include <vector>
#import "FFVector.h"
#import "FFObserver.h"

#ifndef ForceField_FFObject_h
#define ForceField_FFObject_h

class FFObject { 
    
public:
    
    int idNumber;
    
    // Constructors and Destructors
    FFObject() : m_mass(1), m_charge(1), dragging(NO) {};
    ~FFObject() {};
    
    void randomizeValues(float w, float h);
    
    void setPosition(float x, float y){
        m_xPosition = x;
        m_yPosition = y; 
    };
    void setVelocity(float x, float y){
        m_xVelocity = x;
        m_yVelocity = y; 
    };
    void setAcceleration(float x, float y){
        m_xAcceleration = x;
        m_yAcceleration = y; 
    };
    void setSize(float w, float h){
        m_radius = w/2;
    };
    
    void updateAcceleration();
    void updateVelocityWithSeconds(float s);
    void updatePositionWithSeconds(float s);
    void checkBoundaries(float x, float y, float w, float h);
    
    float getX() {return m_xPosition;};
    float getY() {return m_yPosition;};
    float getCenterX() {return m_xPosition+m_radius;};
    float getCenterY() {return m_yPosition+m_radius;};
    float getXVelocity() {return m_xVelocity;};
    float getYVelocity() {return m_yVelocity;};
    float getXAcceleration() {return m_xAcceleration;};
    float getYAcceleration() {return m_yAcceleration;};
    float getCharge() {return m_charge;};
    float getMass() {return m_mass;};
    float getRadius() {return m_radius;};
    float getWidth() {return m_radius*2;};
    float getHeight() {return m_radius*2;};
    
    
    void setX(float f) {m_xPosition = f;};
    void setY(float f) { m_yPosition = f;};
    void setCenterX(float f) { m_xPosition = f - m_radius;};
    void setCenterY(float f) { m_yPosition = f - m_radius;};
    void setXVelocity(float f) { m_xVelocity = f;};
    void setYVelocity(float f) { m_yVelocity = f;};
    void setXAcceleration(float f) { m_xAcceleration = f;};
    void setYAcceleration(float f) { m_yAcceleration = f;};
    void setCharge(float f) { m_charge = f;};
    void setMass(float f) { m_mass = f;};
    void setRadius(float f) { m_radius = f;};
    
    void clearForces() {forceVector.clear();};
    void applyForce(FFVector *vector) {forceVector.push_back(vector);};
    
    id<FFObserver> observer;
    std::vector<FFVector*> forceVector;
    
    BOOL dragging;
    
private:
    
    //pixels
    float m_xPosition;
    float m_yPosition;
    
    //velocity: pixels per second
    float m_xVelocity;
    float m_yVelocity;
    
    //velocity: pixels per second^2
    float m_xAcceleration;
    float m_yAcceleration;
    
    
    float m_mass;
    float m_radius; //pixels
    
    float m_charge;
//	float m_attraction;
    
};

#endif